<?php

use yii\helpers\Html;
use yii\grid\GridView;


$this->title = '舱房信息';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="room-index">

    <h2 class="page-header"><?= Html::encode($this->title) ?>
        <p class="pull-right">
        <?= Html::a('创建舱房', ['create', 'cruise_id'=>$cruise_id], ['class' => 'btn btn-success']) ?>
        <?= Html::a('返回列表', ['cruise/index'], ['class' => 'btn btn-danger']) ?>
        </p>
    </h2>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

   

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'layout'  =>  "{items}\n{pager}",
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            'cruise.name',
            'name',
            'code',
             [
                'attribute' => 'type',
                'filter' =>  Yii::$app->params['room_type'],
                'value' => function ($model) {
                    return Yii::$app->params['room_type'][$model->type];
                },
                'format' => 'raw',
            ],
            [
                'attribute' => 'windows',
                'filter' =>  Yii::$app->params['windows'],
                'value' => function ($model) {
                    return Yii::$app->params['windows'][$model->windows];
                },
                'format' => 'raw',
            ],
            'area',
            [
                'attribute' => 'min',
                'label' => '最小入住人数',
                'value' => function ($model) {
                    return $model->min;
                },
            ],
            'num',
            //'ceil',
            [
                'attribute' => 'ceil',
                //'filter' =>  Yii::$app->params['windows'],
                'value' => function ($model) {
                    $ceil  = json_decode($model->ceil);
                    return !empty($ceil) ? implode(',', $ceil) : '(未设置)';
                },
                'format' => 'raw',
            ],
            //'desc',
            [
                'attribute' => 'status',
                'filter' =>  Yii::$app->params['status'],
                'value' => function ($model) {
                    return Yii::$app->params['status'][$model->status];
                },
                'format' => 'raw',
            ],
            //'user_id',
            //'created_at',
            //'updated_at',

            ['class' => 'yii\grid\ActionColumn','template' =>'{view} {update}'],
        ],
    ]); ?>
</div>
